package com.qst.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qst.dao.UserMapper;
import com.qst.pojo.User;
import com.qst.pojo.UserExample;
import com.qst.service.UserService;
import org.springframework.transaction.annotation.Transactional;

@Service @Transactional public class UserServiceImpl implements UserService {

	 @Autowired private UserMapper userMapper;

	 @Override public boolean insert(User user) throws Exception {
		  return userMapper.insert(user);
	 }

	 @Override public User getUser(Integer id) throws Exception {
		  return userMapper.getUser(id);
	 }

	 @Override public void updateUser(User user) throws Exception {
		  userMapper.updateUser(user);
	 }

	 @Override public User login(User user) throws Exception {
		  User user1 = userMapper.selectByUser(user);
		  return user1;
	 }

	 // 旧版
	 @Override public List<User> userList() throws Exception {
		  // TODO Auto-generated method stub
		  UserExample example = new UserExample();
		  List<User> list = userMapper.selectByExample(example);
		  return list;
	 }

	 @Override public User selectByUserName(String username) throws Exception {
		  return userMapper.selectByUserName(username);
	 }

}
